#include "MsgProcess.h"
#include "common.h"
#include "gobal.h"
#include "LoginManager.h"

CMsgProcess::CMsgProcess()
{

}
CMsgProcess::~CMsgProcess()
{

}

void CMsgProcess::Init(MsgQueue* pMsgQueue)
{
	this->m_pMsgQueue = pMsgQueue;
}


void CMsgProcess::ProcessMsg()
{

}
void CMsgProcess::Run()
{
	while(1)
	{
		::sleep(1);
		int tMsgSize = m_pMsgQueue->GetSize();
		printf("  Msgs size is %d!\n", tMsgSize);
		
		if (tMsgSize < 1)
			continue;

		MSG_HEAD* pMsg = m_pMsgQueue->PopMsg();

		switch(pMsg->MSG_TYPE)
		{
			case 1001:
				{
				printf("Process Msg 1001!\n");
				break;
				}
			case 1002:
				{
				CLoginManager* pLoginServer = CLoginManager::GetInstence();
				USER_LOGIN* pUserLogin = (USER_LOGIN*)pMsg;
				bool bFlag = pLoginServer->CheckUserLogin(pUserLogin->m_sUserName, pUserLogin->m_sPassWord);
				if (bFlag)
				{
					printf("Logining ......\n");
					printf("%s 登录成功！\n", pUserLogin->m_sUserName);
				}
				else
					printf("Login Faile");
					
				break;
				}
			default:
				printf("No right Msg!\n");
		
		
		}
	}
}
